#include <Server.h>
#include <cstring>
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
	
int main()
{

	DataForClientListeningThread data_for_client_listen;

	/*** for resource ***/
	Server server_obj_for_resource;
	server_obj_for_resource.CreateSocket(TCPSOCKET);		// No argument means TCPSOCKET
	server_obj_for_resource.SetSocketOptions();

	// Initialise Server address struct and bind it with Server's socket.
	server_obj_for_resource.InitialiseAddress(5000);		// No argument here will take default port.
	server_obj_for_resource.Bind();
	server_obj_for_resource.DisplayServerInfo();

	HANDLE thread_ID_for_resource;
	thread_ID_for_resource = (HANDLE)_beginthread(ThreadFunctionForResourceListening,0,(void*)&server_obj_for_resource);

	/*** for clients ***/
	Server server_obj_for_clients;
	// Create Server socket and set socket options.
	server_obj_for_clients.CreateSocket(TCPSOCKET);		// No argument means TCPSOCKET
	server_obj_for_clients.SetSocketOptions();

	// Initialise Server address struct and bind it with Server's socket.
	server_obj_for_clients.InitialiseAddress(6000);		// No argument here will take default port.
	server_obj_for_clients.Bind();
	server_obj_for_clients.DisplayServerInfo();

	data_for_client_listen.server_ptr_resource = &server_obj_for_resource;
	data_for_client_listen.server_ptr_clients = &server_obj_for_clients;
	
	HANDLE thread_ID_for_clients;
	thread_ID_for_clients = (HANDLE)_beginthread(ThreadFunctionForClientListening,0,(void*)&data_for_client_listen);
	
	WaitForSingleObject(thread_ID_for_clients, INFINITE);
	WaitForSingleObject(thread_ID_for_resource, INFINITE);
	
	return 0;
}
